package com.my.mr.NumSort;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class NumSortMapper extends Mapper<LongWritable, Text, IntWritable, NullWritable> {
    IntWritable intWritable = new IntWritable();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //最终需要所有的，数字并排序，直接将数字作为key，value为null
        String s = value.toString();
        intWritable.set(Integer.parseInt(s));
        context.write(intWritable, NullWritable.get());
    }
}
